/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author corneliugosa
 */
@Entity
@Table(name = "link_catalogue")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LinkCatalogue.findAll", query = "SELECT l FROM LinkCatalogue l"),
    @NamedQuery(name = "LinkCatalogue.findCatalogueByPerson", query = "SELECT l.catalogue FROM LinkCatalogue l JOIN l.person pers WHERE pers = :person")
})
public class LinkCatalogue implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @JoinColumn(name = "id_person", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Person person;
    @JoinColumn(name = "id_catalogue", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Catalogue catalogue;

    public LinkCatalogue() {
    }

    public LinkCatalogue(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public Catalogue getCatalogue() {
        return catalogue;
    }

    public void setCatalogue(Catalogue catalogue) {
        this.catalogue = catalogue;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LinkCatalogue)) {
            return false;
        }
        LinkCatalogue other = (LinkCatalogue) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.LinkCatalogue[ id=" + id + " ]";
    }
    
}
